package com.rtsffm.rtd.action.registry;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

//~--- classes ----------------------------------------------------------------

class PMultipleExecution implements PExecution {
    private final List<PExecution> _executions = new ArrayList<PExecution>(5);

    //~--- constructors -------------------------------------------------------

    public PMultipleExecution(PExecution... executions_) {
        if (executions_ == null) {
            executions_ = new PExecution[] {};
        }

        _executions.addAll(Arrays.asList(executions_));
    }

    //~--- methods ------------------------------------------------------------

    @Override
    public boolean execute(Object invoker, Object cause, Object context, Object... delegates) {
        for (PExecution exec : _executions) {
            exec.execute(invoker, cause, context);
        }

        return true;
    }

    @Override
    public void addNextExecution(PExecution next) {
        _executions.add(next);
    }
}
